package com.cuit.xsc.weishare.adapter;

import android.app.Activity;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import com.cuit.xsc.weishare.R;
import com.cuit.xsc.weishare.model.UserInfo;

public class AccountManagerAdpter extends ArrayListAdapter<UserInfo>
{

	private Context context;
	
	public AccountManagerAdpter(Activity context)
	{
		super(context);
		this.context = context;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent)
	{
		Holder holder = null;
		UserInfo userInfo = mList.get(position);
		
		if (null == convertView)
		{
			holder = new Holder();
			convertView = LayoutInflater.from(context).inflate(R.layout.accountlistitemview, null);
			holder.ivPoint = (ImageView) convertView.findViewById(R.id.ivPoint);
			holder.tvAccountName = (TextView) convertView.findViewById(R.id.tvAccountName);
			holder.ivTrianle = (ImageView) convertView.findViewById(R.id.ivTrianle);
			
			convertView.setTag(holder);
		}
		else
		{
			holder = (Holder) convertView.getTag();
		}
		
		if (userInfo != null)
		{
			holder.ivPoint.setImageDrawable(userInfo.getUserIcon());
			holder.tvAccountName.setText(userInfo.getUserName());
		}
		
		
		
		return convertView;
	}
	
	class Holder
	{
		ImageView ivPoint;
		TextView tvAccountName;
		ImageView ivTrianle;
		
	}

}
